package aiku.numericalcontroloa.Controller.Products;

import aiku.numericalcontroloa.Base.Utils.Result;
import aiku.numericalcontroloa.Model.Dto.PurchaseReceiptsDto;
import aiku.numericalcontroloa.Service.Impl.PurchaseReceiptsServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 马文杰
 * @version 1.0
 */
@RestController
@RequestMapping("/purchaseReceipts")
@Slf4j
public class PurchaseReceiptsController {
    @Autowired
    private PurchaseReceiptsServiceImpl purchaseReceiptsService;
    /**
     * 库管审核入库单
     * @param receiptsId 采购入库单id
     * receiptsStatus 采购入库单状态
     */
    @PostMapping("/adminCheck")
    public Result adminCheck(@RequestParam("receiptsId") String receiptsId,
                             @RequestParam("receiptsStatus") String receiptsStatus) {
        //TODO 管理员审核入库账单
        Result  result = purchaseReceiptsService.adminCheck(receiptsId, receiptsStatus);
        return result;
    }

    /**
     * 财务审核入库单
     */
    @PostMapping("/financeCheck")
    public Result financeCheck(@RequestParam("receiptsId") String receiptsId,
                               @RequestParam("receiptsStatus") String receiptsStatus) {
        //TODO 财务审核入库账单
        Result  result = purchaseReceiptsService.financeCheck(receiptsId, receiptsStatus);
        return result;
    }

    /**
     * 申请采购入库单
     */
    @PostMapping("/apply")
    public Result apply(@RequestBody PurchaseReceiptsDto purchaseReceiptsDto) {
        //TODO 申请入库账单
        Result  result = purchaseReceiptsService.apply(purchaseReceiptsDto);
        return result;
    }

    /**
     * 查询采购订单列表
     */
    @PostMapping("/purchaseList")
    public Result purchaseList() {
        //TODO 查询入库账单列表
        Result  result = purchaseReceiptsService.purchaseList();
        return result;
    }

    /**
     * 通过入库id查询入库信息
     */
    @PostMapping("/purchaseReceiptsInfo")
    public Result purchaseReceiptsInfo(@RequestParam("receiptsId") String receiptsId) {
        //TODO 管理员审核入库账单
        Result  result = purchaseReceiptsService.purchaseReceiptsInfo(receiptsId);
        return result;
    }

    /**
     * 通过采购订单id，和产品类型一键申请入库
     */
    @PostMapping("/applyInbound")
    public Result applyInbound(@RequestParam("productIds") String productIds) {
        //TODO 查询入库账单列表
        Result  result = purchaseReceiptsService.applyInbound(productIds);
        return result;
    }


    /**
     * 厂长查询审核采购信息
     */
    @PostMapping("selectCheck")
    public Result selectCheck(@RequestParam("page") Integer page,@RequestParam("size") Integer size){
        return purchaseReceiptsService.selectCheck(page,size);
    }


    /**
     * 厂长审核采购信息
     */
    @PostMapping("applyCheck")
    public Result applyCheck(@RequestParam("receiptsId") String receiptsId,@RequestParam("status") String status){
        return purchaseReceiptsService.applyCheck(receiptsId,status);
    }

    /**
     * 分页获取入库列表
     * @param purchaseReceiptsDto
     * @return
     */
    @PostMapping("/getPurchaseReceiptsList")
    public Result getPurchaseReceiptsList(@RequestBody PurchaseReceiptsDto purchaseReceiptsDto){
        return purchaseReceiptsService.getPurchaseReceiptsList(purchaseReceiptsDto);
    }

    /**
     * 审核入库
     * @param purchaseReceiptsDto
     * @return
     */
    @PostMapping("/applyPurchaseReceipts")
    public Result applyPurchaseReceipts(@RequestBody PurchaseReceiptsDto purchaseReceiptsDto){
        return purchaseReceiptsService.applyPurchaseReceipts(purchaseReceiptsDto);
    }

    /**
     * 删除
     * @param purchaseReceiptsDto
     * @return
     */
    @PostMapping("/deletePurchaseReceipts")
    public Result deletePurchaseReceipts(@RequestBody PurchaseReceiptsDto purchaseReceiptsDto){
        return purchaseReceiptsService.deletePurchaseReceipts(purchaseReceiptsDto);
    }
}
